package com.lyf.mapper.admin;

import com.github.pagehelper.Page;
import com.lyf.annotation.AutoFill;
import com.lyf.dto.SetmealDTO;
import com.lyf.dto.SetmealPageQueryDTO;
import com.lyf.enumeration.OperationType;
import com.lyf.pojo.Setmeal;
import com.lyf.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 插入套餐数据
     * @param setmeal
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /**
     * 套餐分页查询
     * @param setmealPageQueryDTO
     * @return
     */
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 查询套餐详情
     * @param id
     * @return
     */

    @Select("select * from setmeal where id = #{id}")
    SetmealVO selectById(Long id);

    /**
     * 批量删除套餐
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    /**
     * 根据id批量查询套餐数据
     * @param ids
     * @return
     */
    List<Setmeal> selectByIds(List<Long> ids);

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Select("select * from setmeal where category_id = #{id}")
    List<SetmealVO> getByCategoryId(Long id);
}
